<template>
    <div>
        <h1>{{$store.state.count}} {{count}}</h1>
        <h2>{{$store.getters.type}}</h2>
        <button @click='add'>+</button>
        <button @click='minus'>+</button>
        <my-button></my-button>
    </div>
</template>
<script>
// 辅助函数
import Button from './components/button'
import {mapState,mapMutations} from './store/myvuex'
export default {
    name: 'XXX',
    data() {
        return {
        
        }
    },
    created() {
      console.log('index',this)
    },
    methods: {
      ...mapMutations(['changeCount']),
      add(){
        this.$store.commit('changeCount',20)
      },
      minus(){
        this.$store.dispatch('changeCountAsync',-5)
      }
    },
    computed:{
      // count(){
      //   return this.$store.state.count
      // }
      ...mapState(['count'])
    },
    components: {
        'my-button':Button
    }
}
</script>
<style lang="less">

</style>